<template>
  <div class="subject">
    <el-carousel height="220px" type="card">
      <el-carousel-item v-for="item in recommendArticleData " :key="item.index">
        <div class="recommendArticleTitle">
          {{ item.articleTitle }}
        </div>
       <el-image :src="item.articleFirstImage" style="z-index:1;width: 100%;height: 100%" @click="articleTitle(item.articleId)"/>
      </el-carousel-item>
    </el-carousel>
  </div>
</template>

<script>
import request from "../../utils/request";
import { gotoNewWindow } from "../../utils/sameMethod";

export default {
  name: "slideShow",
  data: function (){
    return{
      recommendArticleData:[],
    };
  },
  methods: {
    articleTitle(articleId){
      gotoNewWindow(articleId,"content","detail");
    },
    getSlideShow(){
      request.get("/article/initSlideShow").then(res=>{
        this.recommendArticleData=res.data
      })
    }
  },
  mounted() {
    this.getSlideShow()
  }
}
</script>

<style scoped>
.recommendArticleTitle{
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp:1;
  z-index:100;
  position:relative;
  top:80%;
  color: rgb(231, 234, 241);
  font-size: 110%;
  font-weight: bolder;
  text-align: center;
}
.subject{
  margin: 0 auto;
  margin-top: 30px;
  max-width: 980px;
}
</style>